﻿using System;
using System.IO;
namespace Main.File {
    public class File {
        public static void write () {
            string[] names = new string[] { "Zara Ali", "Nuha Ali" };
            using (StreamWriter sw = new StreamWriter ("names.txt")) {
                foreach (string s in names) {
                    sw.WriteLine (s);
                }
            }
            // 从文件中读取并显示每行
            string line = "";
            using (StreamReader sr = new StreamReader ("names.txt")) {
                while ((line = sr.ReadLine ()) != null) {
                    Console.WriteLine (line);
                }
            }
        }
    }
}